import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:${USER}
 * Date:${YEAR}-${MONTH}-${DAY}
 * ${TIME}
 */
public class Main {
    public static void main(String[] args) {
        System.out.println("Hello world!");
    }
}
class Solution {
    public List<Integer> findSubstring(String s, String[] words) {
        List<Integer> list=new ArrayList<>();

        Map<String,Integer> map=new HashMap<>();
        for(String ss : words)map.put(ss,map.getOrDefault(ss,0)+1);//保存窗口里所有单词出现的次数
        int len=words[0].length();
        int m=words.length;

        for(int i=0;i<len;i++){
            int count=0;
            Map<String,Integer> map1=new HashMap<>();
            for(int left=i,right=i;right+len<=s.length();right+=len){//进窗口

                String in=s.substring(right,right+len);
                map1.put(in,map1.getOrDefault(in,0)+1);
                if(map1.get(in)<=map.getOrDefault(in,0))count++;
                if(right-left+1>len*m){//判断
                    String out=s.substring(left,left+len);//出窗口
                    if(map1.get(out)<=map.getOrDefault(out,0))count--;
                    map1.put(out,map1.get(out)-1);
                    left+=len;
                }
                if(m==count){//更新结果
                    list.add(left);
                }
            }
        }
        return list;
    }
}